<?php
	// If Process type is PREVIEW/EDIT/DELETE, Get All variables needed to be displayed by form, Edit SQL & Variable if necessary !!!
	if($process_type == "PREVIEW" || $process_type == "EDIT" || $process_type == "DELETE")
	{
		$sql2 = "	select a.* , b.filename
					from tbl_text a 
						left join ms_file b
							on a.texturlimage = b.fileid and b.stsrc = 'A'
					where a.stsrc = 'A' and a.textid = '".$PK_id."' and a.moduleid = '".$_SESSION['moduleid']."' ";
		$exe2 = mysql_query($sql2) or die(mysql_error());
		$num2 = mysql_num_rows($exe2);
		$row2 = mysql_fetch_array($exe2);
		
		// Set Value if data is found
		if($num2>0)
		{
			$val_text_PK_id = $row2['textid'];
			$val_text_name = $row2['textname'];
			$val_text_label = $row2['textlabel'];
			$val_text_header = sql_quote_html_sc_de($row2['textheader']);
			$val_text_content = sql_quote_html_sc_de($row2['textcontent']);
			$val_text_url_img = $row2['texturlimage'];
			$val_text_img_sts = $row2['texturlimagestatus'];
			$val_text_position = $row2['textposition'];
			$val_text_activate = $row2['textstatus'];
		}
		else
		{
			$val_text_PK_id = "";
			$val_text_name = "";
			$val_text_label = "";
			$val_text_header = "";
			$val_text_content = "";
			$val_text_url_img = "";
			$val_text_img_sts = "";
			$val_text_position = "";
			$val_text_activate = "";
		}
	}
	else
	{
		$val_text_PK_id = "";
		$val_text_name = "";
		$val_text_label = "";
		$val_text_header = "";
		$val_text_content = "";
		$val_text_url_img = "";
		$val_text_img_sts = "";
		$val_text_position = "";
		$val_text_activate = "";
	}
	
?>
<!-- Start Row Data -->
<div class="divFormRowData">
	<div style="float:left; text-align:right; width:<?php echo $rowDivWidth; ?>px;">Name</div>
	<div style="float:left;">&nbsp;:&nbsp;</div>
	<div style="float:left;">
		<input type="hidden" type="text" name="txt_text_name" value="<?php echo $val_text_name; ?>" />
		<input <?php if($process_type == "PREVIEW" || $process_type == "DELETE"){echo "disabled='disabled'";} ?> type="text" required name="txt_text_name" value="<?php echo $val_text_name; ?>" style="width:300px; height:18px;" />
	</div>
	<div style="clear:both;"></div>
</div>
<div class="divFormRowData">
	<div style="float:left; text-align:right; width:<?php echo $rowDivWidth; ?>px;">Label</div>
	<div style="float:left;">&nbsp;:&nbsp;</div>
	<div style="float:left;">
		<input <?php if($process_type == "PREVIEW" || $process_type == "DELETE"){echo "disabled='disabled'";} ?> type="text" required name="txt_text_label" value="<?php echo $val_text_label; ?>" style="width:300px; height:18px;" />
	</div>
	<div style="clear:both;"></div>
</div>
<div class="divFormRowData">
	<div style="float:left; text-align:right; width:<?php echo $rowDivWidth; ?>px;">Header</div>
	<div style="float:left;">&nbsp;:&nbsp;</div>
	<div style="float:left;">
		<textarea <?php if($process_type == "PREVIEW" || $process_type == "DELETE"){echo "disabled='disabled'";} ?> name="txt_text_header" style="width:300px; height:150px; max-width:300px; max-height:150px;"><?php echo textarea_string($val_text_header); ?></textarea>
	</div>
	<div style="clear:both;"></div>
</div>
<div class="divFormRowData">
	<div style="float:left; text-align:right; width:<?php echo $rowDivWidth; ?>px;">Content</div>
	<div style="float:left;">&nbsp;:&nbsp;</div>
	<div style="float:left;">
		<textarea <?php if($process_type == "PREVIEW" || $process_type == "DELETE"){echo "disabled='disabled'";} ?> name="txt_text_content" style="width:300px; height:150px; max-width:300px; max-height:150px;"><?php echo textarea_string($val_text_content); ?></textarea>
	</div>
	<div style="clear:both;"></div>
</div>
<div class="divFormRowData">
	<div style="float:left; text-align:right; width:<?php echo $rowDivWidth; ?>px;">Image</div>
	<div style="float:left;">&nbsp;:&nbsp;</div>
	<div style="float:left;">
		<?php
			$sql3 = "	select a.fileid, a.filelabel, a.filename, b.imagewidth, b.imageheight
						from ms_file a
							left join ms_image b
								on a.fileid = b.fileid
						where a.filerole = 'image' and a.stsrc = 'A' order by a.filelabel asc ";
			$exe3 = mysql_query($sql3) or die(mysql_error());
			$num3 = mysql_num_rows($exe3);
			
			if($num3 > 0)
			{
		?>
		<select <?php if($process_type == "PREVIEW" || $process_type == "DELETE"){echo "disabled='disabled'";} ?> name="txt_text_img_url">
			<option value="-1" >Select Image !</option>
			<?php
				while($row3 = mysql_fetch_array($exe3))
				{
			?>
			<option <?php if($row3['fileid'] == $val_text_url_img){echo "selected=selected";} ?> value="<?php echo $row3['fileid']; ?>" ><?php echo ucwords(strtolower($row3['filelabel'])); if($row3['imagewidth'] && $row3['imageheight']){ echo " - ".$row3['imagewidth']."x".$row3['imageheight'];} ?></option>
			<?php
				}
			?>
		</select>
		<?php
			}
			else
			{
		?>
			<span style="color:#FF0000;">No Data !</span>
		<?php
			}
		?>
	</div>
	<div style="clear:both;"></div>
</div>
<?php 
	if($row2['filename'] != "" || !empty($row2['filename']))
	{
?>
<div class="divFormRowData">
	<div style="float:left; text-align:right; width:<?php echo $rowDivWidth; ?>px;">Preview</div>
	<div style="float:left;">&nbsp;:&nbsp;</div>
	<div style="float:left;">
		<?php echo "<img src='".getURLdomain()."/upload/".file_string($row2['filename'])."' style='max-width:400px; max-height:100px;' />"; ?>
	</div>
	<div style="clear:both;"></div>
</div>
<?php
	}
?>
<div class="divFormRowData">
	<div style="float:left; text-align:right; width:<?php echo $rowDivWidth; ?>px;">Position</div>
	<div style="float:left;">&nbsp;:&nbsp;</div>
	<div style="float:left;">
		<input <?php if($process_type == "PREVIEW" || $process_type == "DELETE"){echo "disabled='disabled'";} ?> type="number" required min="1" max="100" name="txt_text_position" value="<?php echo $val_text_position; ?>" style="width:50px; height:18px; font-size:10px;" />
	</div>
	<div style="clear:both;"></div>
</div>
<div class="divFormRowData">
	<div style="float:left; text-align:right; width:<?php echo $rowDivWidth; ?>px;">Show Image</div>
	<div style="float:left;">&nbsp;:&nbsp;</div>
	<div style="float:left;">
		<input <?php if($process_type == "PREVIEW" || $process_type == "DELETE"){echo "disabled='disabled'";} ?> type="radio" name="rdo_text_img_sts" value="1" <?php if(isset($val_text_img_sts)){if($val_text_img_sts == 1){echo "checked='true'";}} ?> /> Yes
		<input <?php if($process_type == "PREVIEW" || $process_type == "DELETE"){echo "disabled='disabled'";} ?> type="radio" name="rdo_text_img_sts" value="0" <?php if(isset($val_text_img_sts)){if($val_text_img_sts == 0){echo "checked='true'";}} ?> /> No
	</div>
	<div style="clear:both;"></div>
</div>
<div class="divFormRowData">
	<div style="float:left; text-align:right; width:<?php echo $rowDivWidth; ?>px;">Activate</div>
	<div style="float:left;">&nbsp;:&nbsp;</div>
	<div style="float:left;">
		<input type="hidden" name="txt_text_category" value="<?php echo $val_text_category; ?>" style="width:200px; height:18px;" />
		<input type="hidden" name="txt_text_PK_id" value="<?php echo $val_text_PK_id; ?>" style="width:200px; height:18px;" />
		<input <?php if($process_type == "PREVIEW" || $process_type == "DELETE"){echo "disabled='disabled'";} ?> type="radio" name="rdo_text_activate" value="1" <?php if(isset($val_text_activate)){if($val_text_activate == 1){echo "checked='true'";}} ?> /> Yes
		<input <?php if($process_type == "PREVIEW" || $process_type == "DELETE"){echo "disabled='disabled'";} ?> type="radio" name="rdo_text_activate" value="0" <?php if(isset($val_text_activate)){if($val_text_activate == 0){echo "checked='true'";}} ?> /> No
	</div>
	<div style="clear:both;"></div>
</div>
<!-- End Row Data -->